dnl $Id: configure.ac 1.45 06/05/07 17:37:11+03:00 anttit@tcs.hut.fi $
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.57)
AC_INIT([Tisa Project], [0.1], [], tisa)

AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)

AC_CANONICAL_HOST
AC_GNU_SOURCE
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_GCC_TRADITIONAL

AC_PROG_YACC
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_CHECK_PROG([SED], [sed], [sed])
if test -z "$SED"; then
	AC_MSG_ERROR([sed required but not found

*** sed not found in the system.  Install sed to proceed.
])
fi
AC_CHECK_PROG([INDENT], [indent], [indent])
if test -z "$INDENT"; then
	AC_MSG_WARN([
*** indent not found in the system.  If you need to generate pmgr.c and 
*** pmgr.h you need to install indent.
])
fi

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_C_RESTRICT
AC_C_VOLATILE
AC_C_BIGENDIAN
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_HEADER_STDBOOL

AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([arpa/inet.h fcntl.h sys/ioctl.h sys/param.h time.h syslog.h])

dnl Checks for library functions.
AC_FUNC_FORK
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_FUNC_WAIT3
AC_CHECK_FUNCS([memset select socket strdup strerror])

AC_MSG_NOTICE([*** checking for additional external libraries])
AC_CHECK_FUNC([clock_gettime])
if test $ac_cv_func_clock_gettime = no; then
   AC_CHECK_LIB(rt, clock_gettime,,
		[AC_MSG_ERROR([librt required but not found])])
fi

AC_CHECK_LIB(pthread, pthread_create, [], [
	AC_MSG_ERROR([POSIX thread library required but not found.])
])

AC_CHECK_LIB(ncurses, move, [], [
	AC_MSG_ERROR([ncurses library required but not found.])
])

AC_CHECK_LIB(readline, readline, [], [
	AC_MSG_ERROR([readline library required but not found.])
])

dnl Option --enable-debug
AC_ARG_ENABLE(debug,
	AC_HELP_STRING([--enable-debug],[enable debug messages of threads]),
        [ac_cv_enable_debug=$enableval], [ac_cv_enable_debug=no])
if test x$ac_cv_enable_debug = xyes; then
        AC_DEFINE([DEBUG], [1], [Enable debugging threads])
fi
AC_CACHE_CHECK([whether to enable debug messages],
	       [ac_cv_enable_debug], [ac_cv_enable_debug=no])

AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

AC_MSG_NOTICE([settings

AC_PACKAGE_NAME version AC_PACKAGE_VERSION

  Enable debugging mode: .......... $ac_cv_enable_debug

  Build target: $host
])
